$(document).ready(function(){
   $('input[name="str"]').keyup(function(){
      var searchStr = $('input[name="str"]').val(),
          url = $('#search').attr('action');
      $.post(
         url,
         { str: searchStr },
         function(data){
            var content = '<ul>',
            	i = 0,
            	cesta_id = $('.pridat-noveho-cloveka').find('input[name="cesta_id"]').val(),
            	typ_cesty = $('.pridat-noveho-cloveka').find('input[name="typ_cesty"]').val();
            	//console.log(cesta_id);
            	//console.log(typ_cesty);
            $.each(data,function(index, value){
				if( i % 2 === 0 ){
                	content += '<li class="odd">'+ value +' <a href="' + site_base_url + 'people/addExisting/'+typ_cesty+ '/'+cesta_id+'/'+index +'"><b>Priraď</b></a></li>';
              	} else {
              		content += '<li class="even">'+ value + ' <a href="' + site_base_url + 'people/addExisting/'+typ_cesty+ '/'+cesta_id+'/'+index +'"><b>Priraď</b></a></li>';
              	}
              	i++;
                //console.log(index + '--' + value);
            });
            content += '</ul>';
            $('#search-content').empty();
            $('#search-content').append(content);
            //console.log(content);
         },
         'json'
      );
      if( $('input[name="str"]').val() === ''){
         $('#search-content').empty();   
      }
   });

   
});